package com.client.service;

import com.admin.bean.GoodSoftwareType;
import com.client.dbdao.IndexClientDao;
import com.data.util.CheckDataUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 客服端的软件处理服务层
 *
 * @author:HingLo
 * @create 2017-09-27 11:26
 **/
@Service
public class IndexClientService {
    @Autowired
    private IndexClientDao indexClientDao;


    public List<?> findindexClientService(int type) {
        return indexClientDao.findindexClientDao(type);
    }

    public List<?> findindexClientBannerService() {
        return indexClientDao.findindexClientBannerDao();
    }


    /**
     * 查找热榜软件
     *
     * @return
     */
    public List<?> findHotSoftwareService(Object... o) {
        //第一步查询软件的下载量排行榜
        return indexClientDao.findIndexClientDownloadDao(0, o);
    }

    /**
     * 抢先软件
     *
     * @return
     */
    public List<?> findfristSoftwareService(Object... o) {
        //第一步查询软件的下载量排行榜
        return indexClientDao.findIndexClientDownloadDao(2, o);
    }

    public List<?> findGoodSoftwareService(int type) {
        return indexClientDao.findGoodSoftwareDao(type);
    }

    public GoodSoftwareType findGoodSoftwareService(String id) {
        id = id.trim();
        List<GoodSoftwareType> list = indexClientDao.findGoodSoftwareDao(id);
        return list.isEmpty() ? null : list.get(0);
    }

    public List<?> goodChoiceSoftwareService(String id) {
        id = id.trim();
        if (!CheckDataUtils.stringUtilsID(id)) {
            return null;
        }


        return indexClientDao.findGoodChoiceSoftwareDao(id);
    }

    public boolean addSoftwareDownloadsNum(String rid) {
        rid = rid.trim();
        return indexClientDao.addSoftwareDownloadsDao(rid);
    }

    public List<?> indexBannerSoftwareService(String rid) {
        return indexClientDao.indexBannerSoftwareDao(rid);
    }
}
